Crate webbrowser
source · [−]Expand description
Open URLs in the web browsers available on a platform.
Inspired by the webbrowser python library.
Examples
use webbrowser;
if webbrowser::open("http://github.com").is_ok() {
// ...
}
Platform Support Status
Platform | Supported | Browsers | Test status |
---|---|---|---|
macos | ✅ | default + others | ✅ |
windows | ✅ | default only | ✅ |
linux/*bsd | ✅ | default only (respects $BROWSER env var, so can be used with other browsers) | ✅ |
android | ✅ | default only | ✅ |
wasm | ✅ | default only | ✅ |
haiku | ✅ (experimental) | default only | ❌ |
ios | ❌ | unsupported | ❌ |
Consistent Behaviour
webbrowser
defines consistent behaviour on all platforms as follows:
- Non-Blocking for GUI based browsers (e.g. Firefox, Chrome etc.), while Blocking for text based browser (e.g. lynx etc.)
- Suppressed output by default for GUI based browsers, so that their stdout/stderr don’t pollute the main program’s output. This can be overridden by
webbrowser::open_browser_with_options
.
Structs
BrowserOptions to override certain default behaviour. Any option named as a hint
is
not guaranteed to be honoured. Use BrowserOptions::new() to create.
The Error type for parsing a string into a Browser.
Enums
Browser types available
Functions
Opens the URL on the default browser of this platform
Opens the specified URL on the specific browser (if available) requested. Return semantics are the same as for open.
Opens the specified URL on the specific browser (if available) requested, while overriding the default options.